package vn.demand.dragon.controller
{
	import com.salesbuilder.control.TabManager;
	
	import mx.core.Container;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	import vn.demand.dragon.FFIAApplicationFacade;
	import vn.demand.dragon.view.ProjectNewFormMediator;
	
	public class CloseNewProjectPanelCommand extends SimpleCommand
	{
		override public function execute( note:INotification ) :void    
		{
			var projectVO:Object = note.getBody();
			var formId:String = ProjectNewFormMediator.makeId(projectVO);
			RIALogger.debug(this, "CloseNewProjectPanelCommand::execute : formId: " + formId);
			var m:ProjectNewFormMediator = facade.retrieveMediator(formId) as ProjectNewFormMediator;
			var tab:Container = m.projectForm as Container;
			if (tab == null) return;
			facade.removeMediator(formId);
			facade.removeProxy(formId);
			TabManager.removeTab(tab);
			projectVO.project_iso_code = note.getType() as String;
			if (null == projectVO.project_iso_code || '' == projectVO.project_iso_code) {
				return;
			} 
			sendNotification(FFIAApplicationFacade.REFERENCE_SELECTED, projectVO);
        }
	}
}